<?php

session_start();
if(!array_key_exists("user", $_SESSION) || $_SESSION['account'] != 1){
	header("Location: ../common/redirect.php");
	exit;
}

include_once("../class/db.php");
$db = new db();

$sql = "SELECT exams.*, course_content.title FROM exams, course_content WHERE username = {$_SESSION['user']} AND course_content.id = exams.exam_id";
$user_exam_data = $db->execute($sql, "all");

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>PIE EDUCATION | My Records</title>
<link rel="stylesheet" type="text/css" href="/css/style-student.css" />
<link href="/css/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="/js/index.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script language="Javascript1.2">
<!--
setTimeout('location.href="/logout.php?expire=1"',600000);
// -->
</script>
<script>
	$(document).ready(function() {
		$("#accordion").accordion({ autoHeight: false });
	});
</script>
<script type="text/javascript">

  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-35230372-1']);
  _gaq.push(['_trackPageview']);

  (function() {
    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
  })();

</script>
</head>

<body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td bgcolor="#000000"><table width="980" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td width="350" height="30">&nbsp;</td>
        <td align="right" valign="bottom"><a href="class.php" class="top-menu" style="color:#999">MY COURSES</a> <a href="schedule.php" class="top-menu" style="color:#999">CALENDAR</a> <a href="homework.php" class="top-menu" style="color:#999">HOMEWORK</a> <a href="test.php" class="top-menu" style="color:#999">EXAMS</a>  <a href="history.php" class="top-menu" style="color:#999">RECORDS</a> <a href="tools.php" class="top-menu" style="color:#999">TOOLS</a> <a href="/logout.php" class="top-menu" style="color:#999">SIGN OUT</a></td>
      </tr>
	  <tr>
        <td>&nbsp;</td>
        <td align="right" valign="bottom"><a href="/profile/" class="login-menu" style="color:#FFF"><?php echo $_SESSION['name'].' '.$_SESSION['lname']; ?></a> <a href="/common/settings.php" class="login-menu" style="color:#FFF">Change Settings</a> <a href="/common/redirect.php" class="login-menu" style="color:#FFF">My Documents</a> <a href="/network/" class="login-menu" style="color:#FFF">My Network</a></td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td height="30" style="background-image:url(/images/top-bg-student.png); background-repeat:repeat-x">&nbsp;</td>
  </tr>
  <tr>
    <td height="700" valign="top"><table width="980" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td>
        <div id="accordion">
            <h3><a href="#">My Exams</a></h3>
            <div>
            <?php
			if($user_exam_data == false){
              echo '<table width="100%" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td height="100" align="center" style="font-family:Arial, Helvetica, sans-serif; font-size:14px; color: #666"><strong>No exams found, your test results will appeaar on this section once you finish them</strong></td>
                </tr>
              </table>';
			} else {
              echo '<table width="100%" border="0" cellspacing="4" cellpadding="4">
                <tr>
                  <td style="font-size:14px; font-family:Arial, Helvetica, sans-serif;border-bottom-color:#CCC; border-bottom:thin; border-bottom-style:dashed; padding-bottom:10px" width="32%"><strong>Title</strong></td>
                  <td width="20%" align="center" style="font-size:14px; font-family:Arial, Helvetica, sans-serif;border-bottom-color:#CCC; border-bottom:thin; border-bottom-style:dashed; padding-bottom:10px"><strong>Apply date</strong></td>
                  <td width="12%" align="center" style="font-size:14px; font-family:Arial, Helvetica, sans-serif;border-bottom-color:#CCC; border-bottom:thin; border-bottom-style:dashed; padding-bottom:10px"><strong>Questions</strong></td>
                  <td width="12%" align="center" style="font-size:14px; font-family:Arial, Helvetica, sans-serif;border-bottom-color:#CCC; border-bottom:thin; border-bottom-style:dashed; padding-bottom:10px"><strong>Right</strong></td>
                  <td width="12%" align="center" style="font-size:14px; font-family:Arial, Helvetica, sans-serif;border-bottom-color:#CCC; border-bottom:thin; border-bottom-style:dashed; padding-bottom:10px"><strong>Wrong</strong></td>
                  <td width="12%" align="center" style="font-size:14px; font-family:Arial, Helvetica, sans-serif;border-bottom-color:#CCC; border-bottom:thin; border-bottom-style:dashed; padding-bottom:10px"><strong>Grade</strong></td>
                  </tr>';
				  foreach($user_exam_data as $exam_data){
					echo '<tr>
					  <td style="font-family:Arial, Helvetica, sans-serif; font-size:12px"><a href="view_history.php?id='.$exam_data['id'].'" title="Click to view full details">'.$exam_data['title'].'</a></td>
					  <td align="center" style="font-family:Arial, Helvetica, sans-serif; font-size:12px">'.$exam_data['applied'].'</td>
					  <td align="center" style="font-family:Arial, Helvetica, sans-serif; font-size:12px">'.$exam_data['total_questions'].'</td>
					  <td align="center" style="font-family:Arial, Helvetica, sans-serif; font-size:12px">'.$exam_data['total_good'].'</td>
					  <td align="center" style="font-family:Arial, Helvetica, sans-serif; font-size:12px">'.$exam_data['total_bad'].'</td>
					  <td align="center" style="font-family:Arial, Helvetica, sans-serif; font-size:12px">'.$exam_data['total_result'].'</td>
					  </tr>';
				  }
              echo '</table>';
			}
			  ?>
            </div>
            <h3><a href="#">Section 2</a></h3>
            <div>
                <p>
                Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet
                purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor
                velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In
                suscipit faucibus urna.
                </p>
            </div>
            <h3><a href="#">Section 3</a></h3>
            <div>
                <p>
                Nam enim risus, molestie et, porta ac, aliquam ac, risus. Quisque lobortis.
                Phasellus pellentesque purus in massa. Aenean in pede. Phasellus ac libero
                ac tellus pellentesque semper. Sed ac felis. Sed commodo, magna quis
                lacinia ornare, quam ante aliquam nisi, eu iaculis leo purus venenatis dui.
                </p>
                <ul>
                    <li>List item one</li>
                    <li>List item two</li>
                    <li>List item three</li>
                </ul>
            </div>
            <h3><a href="#">Section 4</a></h3>
            <div>
                <p>
                Cras dictum. Pellentesque habitant morbi tristique senectus et netus
                et malesuada fames ac turpis egestas. Vestibulum ante ipsum primis in
                faucibus orci luctus et ultrices posuere cubilia Curae; Aenean lacinia
                mauris vel est.
                </p>
                <p>
                Suspendisse eu nisl. Nullam ut libero. Integer dignissim consequat lectus.
                Class aptent taciti sociosqu ad litora torquent per conubia nostra, per
                inceptos himenaeos.
                </p>
            </div>
        </div>
        </td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td height="30" style=" background-image:url(../images/bottom-bg-student.png); background-repeat:repeat-x;">&nbsp;</td>
  </tr>
  <tr>
    <td height="50" align="center" bgcolor="#000000" style="color:#fff; font-family:Arial, Helvetica, sans-serif">PIE.EDU All Rights Reserved 2012<br />
      <a href="/common/privacy.php" class="bottom-menu" style="color:#999">Privacy Policy</a> | <a href="/common/terms.php" class="bottom-menu"  style="color:#999">Terms of Use</a> | <a href="/help/main.php" class="bottom-menu" style="color:#999">Help Center</a> | <a href="/common/jobs.php" class="bottom-menu" style="color:#999">Jobs</a></td>
  </tr>
</table>
</body>
</html>